/*
 * comboBoxWizard7.java
 *
 * Created on May 21, 2006, 12:27 AM
 */


import javax.swing.*;
import java.sql.*;
import com.mysql.jdbc.Driver;
import static java.lang.System.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
/**
 *
 * @author  yaco
 */
public class ComboBoxWizard7 extends javax.swing.JFrame {
String fieldNameInput;
String tableNameInput;
    /** Creates new form comboBoxWizard */
    public ComboBoxWizard7() {
        
        initComponents();
        this.setSize(550,350);
        this.setLocation(250,200);
        tableNameInput=ComboBoxWizard1.comboBoxWizard1.mainFrame.getTableName();
        for(int i=0;i<MainWindow.dbCon.getFields(ComboBoxWizard1.comboBoxWizard1.mainFrame.getTableName()).size();i++){
            jComboBox1.addItem(MainWindow.dbCon.getFields(ComboBoxWizard1.comboBoxWizard1.mainFrame.getTableName()).elementAt(i));
        }
        jTextField1.setText((String)jComboBox1.getSelectedItem());
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        buttonGroup1 = new javax.swing.ButtonGroup();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jComboBox1 = new javax.swing.JComboBox();

        getContentPane().setLayout(null);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Combo Box Wizard");
        setBackground(new java.awt.Color(204, 204, 204));
        setIconImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("mysql.JPEG")));
        setResizable(false);
        getAccessibleContext().setAccessibleName("frame1");
        jButton1.setText("Cancel");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        getContentPane().add(jButton1);
        jButton1.setBounds(130, 280, 80, 23);

        jButton2.setText("<  Back");
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });

        getContentPane().add(jButton2);
        jButton2.setBounds(260, 280, 90, 23);

        jButton3.setText("Next  >");
        jButton3.setEnabled(false);
        jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton3MouseClicked(evt);
            }
        });

        getContentPane().add(jButton3);
        jButton3.setBounds(350, 280, 90, 23);

        jButton4.setText("Finish");
        jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton4MouseClicked(evt);
            }
        });

        getContentPane().add(jButton4);
        jButton4.setBounds(440, 280, 90, 23);

        getContentPane().add(jSeparator1);
        jSeparator1.setBounds(0, 0, 0, 2);

        getContentPane().add(jSeparator2);
        jSeparator2.setBounds(10, 260, 520, 20);

        jLabel2.setText("Select Target field from this combo box");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(180, 30, 310, 14);

        jLabel3.setText("Those are all the answers the wizard needs to create your combo box.");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(100, 180, 410, 14);

        jTextField1.setEditable(false);
        getContentPane().add(jTextField1);
        jTextField1.setBounds(160, 130, 220, 19);

        jComboBox1.addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
            public void popupMenuCanceled(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {
                jComboBox1PopupMenuWillBecomeInvisible(evt);
            }
            public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {
            }
        });

        getContentPane().add(jComboBox1);
        jComboBox1.setBounds(220, 70, 130, 22);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBox1PopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_jComboBox1PopupMenuWillBecomeInvisible
// TODO add your handling code here:
        jTextField1.setText((String)jComboBox1.getSelectedItem());
        fieldNameInput=jTextField1.getText();
    }//GEN-LAST:event_jComboBox1PopupMenuWillBecomeInvisible

    private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton4MouseClicked
   // TODO add your handling code here:
 ComboBoxWizard1.comboBoxWizard1.mainFrame.namesCount[MyToolBox.COMBOBOX]++;
 ComboBoxWizard1.comboBoxWizard1.mainFrame.component = new MyComboBoxContainer("Combobox"+ComboBoxWizard1.comboBoxWizard1.mainFrame.namesCount[MyToolBox.COMBOBOX],ComboBoxWizard1.comboBoxWizard1.mainFrame);
 ComboBoxWizard1.comboBoxWizard1.mainFrame.component.getComponent().setName("Combobox"+ComboBoxWizard1.comboBoxWizard1.mainFrame.namesCount[MyToolBox.COMBOBOX]);
 this.dispose();
 ComboBoxWizard1.comboBoxWizard1.mainFrame.addComponent(ComboBoxWizard1.comboBoxWizard1.mainFrame.component);
    }//GEN-LAST:event_jButton4MouseClicked

    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
// TODO add your handling code here:
        this.dispose();
        if (ComboBoxWizard1.comboBoxWizard1.flag==false)
        {
                    ComboBoxWizard1.comboBoxWizard2.setVisible(true);
        }
        else
        {
                    ComboBoxWizard1.comboBoxWizard6.setVisible(true);
        }
    }//GEN-LAST:event_jButton2MouseClicked

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
    this.dispose();
// TODO add your handling code here:
    }//GEN-LAST:event_jButton1MouseClicked

    private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked
     
// TODO add your handling code here:
    }//GEN-LAST:event_jButton3MouseClicked
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                
                 ComboBoxWizard1.comboBoxWizard3.setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables
    
}
